﻿namespace HRM.CORE.Machine
{
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using Extra;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;

    public class xfmSelectFromDateToDate : XtraForm
    {
        private SimpleButton btOK;
        private IContainer components;
        private DateEdit dtFromDate;
        private DateEdit dtToDate;
        private GroupBox groupBox1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;

        public event DeselectedEventHander Deselected;

        public event SelectedEventHander Selected;

        public xfmSelectFromDateToDate()
        {
            this.components = null;
            this.InitializeComponent();
            this.dtFromDate.DateTime = DateTime.Now;
            this.dtToDate.DateTime = DateTime.Now;
        }

        public xfmSelectFromDateToDate(DateTime FromDate, DateTime ToDate)
        {
            this.components = null;
            this.InitializeComponent();
            this.dtFromDate.DateTime = FromDate;
            this.dtToDate.DateTime = ToDate;
        }

        private void btOK_Click(object sender, EventArgs e)
        {
            this.RaiseSelectedEventHander(this.dtFromDate.DateTime, this.dtToDate.DateTime);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.groupBox1 = new GroupBox();
            this.labelControl1 = new LabelControl();
            this.btOK = new SimpleButton();
            this.dtFromDate = new DateEdit();
            this.labelControl2 = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.dtToDate = new DateEdit();
            this.groupBox1.SuspendLayout();
            this.dtFromDate.Properties.VistaTimeProperties.BeginInit();
            this.dtFromDate.Properties.BeginInit();
            this.dtToDate.Properties.VistaTimeProperties.BeginInit();
            this.dtToDate.Properties.BeginInit();
            base.SuspendLayout();
            this.groupBox1.Controls.Add(this.dtToDate);
            this.groupBox1.Controls.Add(this.labelControl3);
            this.groupBox1.Controls.Add(this.labelControl2);
            this.groupBox1.Controls.Add(this.dtFromDate);
            this.groupBox1.Location = new Point(0x10, 0x30);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x151, 0x4c);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.labelControl1.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl1.Location = new Point(0x10, 0x10);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x15a, 0x1a);
            this.labelControl1.TabIndex = 1;
            this.labelControl1.Text = "Chọn khoảng thời gian để cập nhật dữ liệu v\x00e0o bảng chấm c\x00f4ng th\x00e1ng";
            this.btOK.Image = MsgResc.page_white_g;
            this.btOK.Location = new Point(0x106, 0x89);
            this.btOK.Name = "btOK";
            this.btOK.Size = new Size(0x5b, 0x17);
            this.btOK.TabIndex = 2;
            this.btOK.Text = "Đồng \x00dd";
            this.btOK.Click += new EventHandler(this.btOK_Click);
            this.dtFromDate.EditValue = null;
            this.dtFromDate.Location = new Point(0x3b, 0x20);
            this.dtFromDate.Name = "dtFromDate";
            this.dtFromDate.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.dtFromDate.Properties.Appearance.Options.UseFont = true;
            this.dtFromDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtFromDate.Properties.Mask.EditMask = "dd/MM/yyyy";
            this.dtFromDate.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.dtFromDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtFromDate.Size = new Size(100, 20);
            this.dtFromDate.TabIndex = 0;
            this.labelControl2.Location = new Point(7, 0x23);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x2c, 13);
            this.labelControl2.TabIndex = 2;
            this.labelControl2.Text = "Từ ng\x00e0y:";
            this.labelControl3.Location = new Point(0xa7, 0x23);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x33, 13);
            this.labelControl3.TabIndex = 3;
            this.labelControl3.Text = "Đến ng\x00e0y:";
            this.dtToDate.EditValue = null;
            this.dtToDate.Location = new Point(0xde, 0x20);
            this.dtToDate.Name = "dtToDate";
            this.dtToDate.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.dtToDate.Properties.Appearance.Options.UseFont = true;
            this.dtToDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtToDate.Properties.Mask.EditMask = "dd/MM/yyyy";
            this.dtToDate.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.dtToDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtToDate.Size = new Size(100, 20);
            this.dtToDate.TabIndex = 4;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(370, 0xa9);
            base.Controls.Add(this.btOK);
            base.Controls.Add(this.labelControl1);
            base.Controls.Add(this.groupBox1);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmSelectFromDateToDate";
            base.Padding = new Padding(4);
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "T\x00f9y chọn";
            base.FormClosed += new FormClosedEventHandler(this.xfmSelectFromDateToDate_FormClosed);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.dtFromDate.Properties.VistaTimeProperties.EndInit();
            this.dtFromDate.Properties.EndInit();
            this.dtToDate.Properties.VistaTimeProperties.EndInit();
            this.dtToDate.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void RaiseDeselectedEventHander()
        {
            if (this.Deselected != null)
            {
                this.Deselected(this);
            }
        }

        private void RaiseSelectedEventHander(DateTime FromDate, DateTime ToDate)
        {
            if (this.Selected != null)
            {
                this.Selected(this, FromDate, ToDate);
            }
        }

        private void xfmSelectFromDateToDate_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.RaiseDeselectedEventHander();
        }

        public delegate void DeselectedEventHander(object sender);

        public delegate void SelectedEventHander(object sender, DateTime FromDate, DateTime ToDate);
    }
}

